using System.Diagnostics;
using Microsoft.Practices.EnterpriseLibrary.Common.Configuration;
using Microsoft.Practices.EnterpriseLibrary.Logging;

namespace FU.Capstones.IMS.Services.Common
{
    public static class Log
    {
        private static readonly LogWriter logger = EnterpriseLibraryContainer.Current.GetInstance<LogWriter>();
        public static void Info(string message, params object[] args)
        {
            var logEntry = new LogEntry
            {
                Message = string.Format(message, args),
                Priority = Priority.Low,
                Severity = TraceEventType.Information
            };
            logEntry.Categories.Add(Category.General);
            logger.Write(logEntry);
        }

        public static void Verbose(string message, params object[] args)
        {
            var logEntry = new LogEntry
            {
                Message = string.Format(message, args),
                Priority = Priority.Low,
                Severity = TraceEventType.Verbose
            };
            logEntry.Categories.Add(Category.General);
            logger.Write(logEntry);
        }

        public static void Warn(string message, params object[] args)
        {
            var logEntry = new LogEntry
            {
                Message = string.Format(message, args),
                Priority = Priority.Low,
                Severity = TraceEventType.Warning
            };
            logEntry.Categories.Add(Category.General);
            logger.Write(logEntry);
        }

        public static void Error(string message, params object[] args)
        {
            var logEntry = new LogEntry
            {
                Message = string.Format(message, args),
                Priority = Priority.High,
                Severity = TraceEventType.Error
            };
            logEntry.Categories.Add(Category.General);
            logEntry.Categories.Add(Category.Error);
            logger.Write(logEntry);
        }

    }
}